
* Create 
* Figure 3(a) Acceptability of 256 prospective peace agreements for Israelis (x-axis) and Palestinians (y-axis). 
* Figure 3(b) Deals in the ZOPA. 

run "$rootfolder\Dofiles\preparation_to_Fig.3(a)(b).do"

mkmat a b c d e f g h, matrix(X) 

* Variances Palestine
forvalues j = 1/256 {
	matrix P_Varpred_elem = X[`j', 1..8]*P_V*X[`j', 1..8]'
	if `j'==1 matrix P_Varpred = [P_Varpred_elem]
	else matrix P_Varpred = [P_Varpred \ P_Varpred_elem]
}

matrix list P_Varpred

* Variances Israel
forvalues j = 1/256 {
	matrix I_Varpred_elem = X[`j', 1..8]*I_V*X[`j', 1..8]'
	if `j'==1 matrix I_Varpred = [I_Varpred_elem]
	else matrix I_Varpred = [I_Varpred \ I_Varpred_elem]
}

matrix list I_Varpred


svmat P_Varpred
svmat I_Varpred

* Creating the standard errors of predictions for each of the 256 cards
gen P_stdpred =  sqrt(P_Varpred)
gen I_stdpred =  sqrt(I_Varpred)


gen P_low  = P_uvalue256-(P_stdpred) 
gen P_high = P_uvalue256+(P_stdpred)  
gen I_low  = I_uvalue256-(I_stdpred) 
gen I_high = I_uvalue256+(I_stdpred)  

* Identify the cards whose CIs (calculated from the point of view of Palestinians) cross the 45 degree line:
* In the 45 line I_uvalue256=P_uvalue256, so we define the tag=1 if the CI includes I_uvalue256
gen tag_crossed45line = .
replace tag_crossed45line = 1 if I_uvalue256 >= P_low & I_uvalue256 <= P_high
list cardname I_uvalue256 P_low P_high tag_cross if tag_crossed45==1

* Figure 3(a) Acceptability of 256 prospective peace agreements for Israelis (x-axis) and Palestinians (y-axis). 
twoway ///
	(scatter P_uvalue256 I_uvalue256 ,   msize(small) mcolor(black%40)) ///
	(scatter P_uvalue256 I_uvalue256 if number_continuous==42,  mlabcolor(black%70) mlcolor(black%70) msize(medlarge) msymbol(Sh)) /// diamond hollow 
, ///
xline(0, lpattern(-) lc(gray)) ///
yline(0, lpattern(-) lc(gray)) ///
yt(" " "Palestinians `Acceptability'") ///
xt(" " "Israelis `Acceptability'") text(.42 0.2 "Nash" 0.02 -0.10 "Status quo", size(vsmall)) ///
legend(off) ///
graphregion(fcolor(white)) 
graph display, ysize(1) xsize(1)

